<?php if($pu == 'pu'):?>
<?php foreach($data as $v):?>
<tr>
    <td><img src="/<?php echo cutUrl($v['avatar'],80,40)?>" alt=""></td>
    <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
    <td style="line-height: 40px"><?php echo $v['content']?></td>
    <td style="line-height: 40px"><?php echo $v['like']?></td>
    <td style="line-height: 40px"><?php echo $v['create_time']?></td>
    <td>

        <a href="javascript:;" data-id="<?php echo $v['id']?>" class="btn btn-danger btn-xs delete">删除</a>

    </td>
</tr>
<?php endforeach;?>
<?php else:?>
<table class="table table-hover" id="show-comment-lists">
    <tr>
        <th style="border:none;">用户头像</th>
        <th style="border:none;">评论用户</th>
        <th style="border:none;">评论内容</th>
        <th style="border:none;">点赞数量</th>
        <th style="border:none;">评论时间</th>
        <th style="border:none;">操作</th>
    </tr>
    <?php foreach($data as $v):?>
    <tr>
        <td><img style="border-radius: 50%" src="/<?php echo cutUrl($v['avatar'],40,40)?>" alt=""></td>
        <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
        <td style="line-height: 40px"><?php echo $v['content']?></td>
        <td style="line-height: 40px"><?php echo $v['likes']?></td>
        <td style="line-height: 40px"><?php echo $v['create_time']?></td>
        <td>

            <a href="javascript:;" data-id="<?php echo $v['id']?>" class="btn btn-danger btn-xs delete">删除</a>

        </td>
    </tr>
    <?php endforeach;?>
</table>
<script>

    $(function(){

        //删除一条评论
        $('#show-comment-lists').undelegate('.delete','click');
        $('#show-comment-lists').delegate('.delete','click',function(){

            var _this = $(this);

            var id = $(this).data('id');

            layer.msg('确定要删除吗?删除之后不可恢复!',{
                    time: 0 //不自动关闭
                    ,btn: ['删除', '取消']
                    ,yes: function(index){

                        layer.close(index);

                        $.post('<?php echo U("Admin/Activity/Index/deleteShowComment")?>',{'id':id},function(result){

                            showMessage(result.msg,result.code,'','',2000);

                            if(result.code == 200) {

                                _this
                                        .parent()
                                        .parent()
                                        .fadeOut(200,function(){

                                            $(this).remove();

                                        })

                            }

                        })

                    }
                }
            );

        });

    });

</script>
<?php endif;?>